package com.spring.shiro.service;

import com.spring.shiro.entity.UserRole;
import com.spring.shiro.mapper.UserRoleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.Arrays;
import java.util.List;

@Service
public class UserRoleService {

    @Autowired
    private UserRoleMapper userRoleMapper;

    public void deleteUserRolesByUserId(String userIds) {
        List<String> list = Arrays.asList(userIds.split(","));
        Example example = new Example(UserRole.class);
        example.createCriteria().andIn("userId", list);

        this.userRoleMapper.deleteByExample(example);
    }

    public void deleteUserRolesByRoleId(String roleIds) {
        List<String> list = Arrays.asList(roleIds.split(","));
        Example example = new Example(UserRole.class);
        example.createCriteria().andIn("roleId", list);

        this.userRoleMapper.deleteByExample(example);

    }


}
